package vn.sunnet.backviet01.game.coloa.util;

import java.util.Timer;
import java.util.TimerTask;

public class CoolDown {
	private long delay;
	private Timer timer;
	private boolean valid;

	public CoolDown() {
		this.timer = new Timer();
		this.valid = true;
	}

	public void setDelay(long delay) {
		this.delay = delay;
	}
	
	public boolean checkValidity() {
		if (valid) {
			this.valid = false;
			this.timer.schedule(new Task(), this.delay);
			return true;
		}
		return false;
	}

	class Task extends TimerTask {

		public void run() {
			valid = true;
		}
	}
}
